package com.jackchong.common;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.core.app.ActivityOptionsCompat;

import com.gyf.barlibrary.ImmersionBar;
import com.jackchong.base.EmptyHeaderActivity;

/**
 * author : jack(黄冲)
 * e-mail : 907755845@qq.com
 * create : 2019/4/22
 * desc   : 大图查看界面
 */
public class PhotoActivity extends EmptyHeaderActivity {

    public static void start(Context context, String imageUrl) {
        Intent intent = new Intent(context, PhotoActivity.class);
        intent.putExtra("imageUrl", imageUrl);
        context.startActivity(intent);
    }

    public static void start(Activity activity, String imageUrl, @NonNull View sharedElement) {
        Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElement,"shareElement").toBundle();
        Intent intent = new Intent(activity, PhotoActivity.class);
        intent.putExtra("imageUrl", imageUrl);
        activity.startActivity(intent, bundle);
    }


    public static void start(Context context, int imageResource) {
        Intent intent = new Intent(context, PhotoActivity.class);
        intent.putExtra("imageResource", imageResource);
        context.startActivity(intent);
    }

    public static void start(Activity activity, int imageResource, @NonNull View sharedElement) {
        Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElement,"shareElement").toBundle();
        Intent intent = new Intent(activity, PhotoActivity.class);
        intent.putExtra("imageResource", imageResource);
        activity.startActivity(intent, bundle);
    }


    @Override
    protected boolean autoSoftKeyboard() {
        return false;
    }

    @Override
    protected void initToolbarColor() {
        ImmersionBar.with(this).statusBarDarkFont(false).init();
    }

    @Override
    protected void onCreateView(Bundle savedInstanceState) {
        addContentView(R.layout.act_photo);

       /* PhotoView photoView = findViewById(R.id.photoView);

        String imageUrl = getIntent().getStringExtra("imageUrl");
        int imageResource = getIntent().getIntExtra("imageResource", 0);

        if (imageUrl != null) {
            RequestOptions options = new RequestOptions();
            Glide.with(mActivity)
                    .load(imageUrl)
                    .apply(options)
//                .error(R.drawable.img_error)
//                .placeholder(R.drawable.img_error)
                    .into(photoView);
        }
        if (imageResource != 0){
            photoView.setImageResource(imageResource);
        }


        photoView.setOnViewTapListener((view, x, y) -> {
            finishActivity();
        });

        photoView.setOnLongClickListener(v -> {
//            WindowManager.showSaveBitmap(mActivity, mBitmap);
            return false;
        });*/
    }

}
